import request from '@/utils/request'
import Qs from 'qs'
import { encryptionData } from '@/utils/com'
const VUE_APP_API = process.env.VUE_APP_API
import {
  parseParams
} from '@/utils/index'
// 质保金明细-按明细分
export function merchantWarrantyDetailsList(data) {
  return request({
    method: "get",
    url: "/jcd-payment/accountLog/page",
    headers: encryptionData(data, '/personAccount/save'),
    params: data
  });
}
// 开通账户
export const tips = {
  // 个人开户
  aloneOpenAccount(data) {
    return request({
      method: 'post',
      url: '/jcd-payment/tlPaymentAccount/personAccount/save',
      headers: encryptionData(data, '/personAccount/save'),
      data: Qs.stringify(data),
    })
  },
  // 个人开户获取验证码
  aloneRegSmsCode(data) {
    return request({
      method: 'post',
      url: '/jcd-payment/tlPaymentAccount/verificationCode',
      headers: encryptionData(data, '/tlPaymentAccount/verificationCode'),
      params: data
    })
  },
  // 企业开户
  openAccount(data) {
    return request({
      method: 'post',
      url: '/jcd-payment/tlPaymentAccount/comAccount/save',
      headers: encryptionData(data, '/comAccount/save'),
      data: Qs.stringify(data),
    })
  },
  // 获取开户信息 
  getUserAcctInfo(data) {
    return request({
      method: 'get',
      url: '/jcd-payment/tlPaymentAccount/getInfo',
      headers: encryptionData(data, '/tlPaymentAccount/getInfo'),
      params: data,
    })
  },
  // 绑定手机号  123
  bindMobile(data) {
    return request({
      method: 'post',
      url: '/jcd-payment/tlPaymentAccount/bindMobile',
      headers: encryptionData(data, '/private/bindMobile'),
      data: Qs.stringify(data)
    })
  },
  // 获取签约链接
  getSignContractLink(data) {
    return request({
      method: 'get',
      url: '/jcd-payment/tlPaymentAccount/signContractLink',
      headers: encryptionData(data, '/tlPaymentAccount/signContractLink'),
      params: data,
    })
  },
  // 获取支付行号 123
  getUnionBank(data) {
    return request({
      method: 'get',
      url: '/jcd-payment/tlPaymentAccountCard/unionBank/list',
      headers: encryptionData(data, '/unionBank/list'),
      params: data,
    })
  },
  // 卡bin查询，输入银行卡号查询信息
  queryCardBin(data) {
    return request({
      method: 'post',
      url: '/jcd-payment/tlPaymentAccountCard/cardBin',
      headers: encryptionData(data, '/tlPaymentAccountCard/cardBin'),
      data: Qs.stringify(data),
    })
  }
}
// 我的钱包
export const wallet = {
  // 列表
  list(data) {
    return request({
      method: 'get',
      url: '/jcd-payment/accountLog/page',
      headers: encryptionData(data, '/accountLog/page'),
      params: data,
    })
  },
  //   没用到
  merchantMarketLogStatistics(data) {
    return request({
      method: 'get',
      url: '/pc/merchantMarketLog/private/statistics',
      headers: encryptionData(data, '/private/statistics'),
      params: data
    })
  },
  // 收益明细
  incomeDetail(data) {
    return request({
      method: 'get',
      url: '/jcd-payment/accountLog/page',
      headers: encryptionData(data, '/accountLog/page'),
      params: data
    })
  },
  // 查询账户余额
  getAccount(data) {
    return request({
      method: 'get',
      url: '/jcd-payment/account/getInfo',
      headers: encryptionData(data, '/jcd-payment/account/getInfo'),
      params: data,
    })
  },
  // 查询已绑定的银行卡信息
  getBindCardList(data) {
    return request({
      method: 'get',
      url: '/jcd-payment/tlPaymentAccountCard/list',
      headers: encryptionData(data, 'tlPaymentAccountCard/list'),
      params: data,
    })
  },
  // 解绑银行卡
  unbindBankCard(data) {
    return request({
      method: 'post',
      url: '/jcd-payment/tlPaymentAccountCard/unbind',
      headers: encryptionData(data, '/tlPaymentAccountCard/unbind'),
      data: Qs.stringify(data),
    })
  },
  // 第一步 绑卡申请，通过银行卡和手机号获取绑卡流水号
  bindCardSupply(data) {
    return request({
      method: 'post',
      url: '/jcd-payment/tlPaymentAccountCard/bindSupply',
      headers: encryptionData(data, '/tlPaymentAccountCard/bindSupply'),
      data: Qs.stringify(data),
    })
  },
  // 第二步 绑卡确认
  bindCard(data) {
    return request({
      method: 'post',
      url: '/jcd-payment/tlPaymentAccountCard/bindConfirm',
      headers: encryptionData(data, '/tlPaymentAccountCard/bindConfirm'),
      data: Qs.stringify(data),
    })
  },
  // 绑卡或者解绑发送验证码
  regSmsCode(data) {
    return request({
      method: 'post',
      url: '/jcd-payment/tlPaymentAccount/verificationCode',
      headers: encryptionData(data, '/tlPaymentAccount/verificationCode'),
      params: data,
    })
  },
  // 提现
  withdrawal(data) {
    return request({
      method: 'post',
      url: '/jcd-payment/tlPaymentOrder/withdraw',
      headers: encryptionData(data, '/tlPaymentOrder/withdraw'),
      data: Qs.stringify(data),
    })
  },
  // 提现记录
  withdrawalRecord(data) {
    return request({
      method: 'get',
      url: '/jcd-payment/tlPaymentOrder/withdraw/page',
      headers: encryptionData(data, '/withdraw/page'),
      params: data,
    })
  },
  // merchantShopDetail(merchantId) {
  //   return request({
  //     url: `/product/merchant/private/info/${merchantId}`,
  //     method: "GET"
  //   });
  // },
  // // 营销费用列表
  // merchantMarketLogPage(data) {
  //   return request({
  //     url: "/pc/merchantMarketLog/private/page",
  //     method: "get",
  //     params: data
  //   })
  // },
    //导出
  // 收益户导出
  detailExport(data) {
    const a = document.createElement("a");
    let baseUrl = `${VUE_APP_API}/pc/accountStatistics/public/account/income/detail/export`;
    a.href = `${baseUrl}?${ parseParams(data)}`
    a.click()
  },
  // 获取我的钱包-账户信息  没用到
  accountInfo() {
    return request({
      method: "get",
      headers: encryptionData(data, '/private/substation/info'),
      url: "/pc/accountStatistics/private/substation/info"
    });
  },
  // 退款金账户充值  没用到
  warrantyDepositRecharge(data) {
      return request({
        method: "post",
        url: "/jcd-payment/account/private/warrantyDepositRecharge",
        headers: encryptionData(data, '/merchantBrand/page'),
        data: Qs.stringify(data)
      });
    },
}
// 质保金
export const warranty = {
  // 列表
  list(data) {
    return request({
      method: 'get',
      url: '/pc/accountStatistics/private/merchant/warrantyDepositDetail',
      headers: encryptionData(data, '/merchant/warrantyDepositDetail'),
      params: data,
    })
  },
  // 查询详情信息，质保金金额等
  detailInfo(data) {
    return request({
      method: 'get',
      url: '/pc/tbPurchaseOrder/private/merchant/list',
      headers: encryptionData(data, '/private/merchant/list'),
      params: data,
    })
  },
  // 重新获取支付验证码
  orderPayPayOrderResend(data) {
    return request({
      url: `/jcd-payment/tlPaymentOrder/private/orderPay/payOrderResend/${data.orderNo}`,
      headers: encryptionData(data, '/merchantBrand/page'),
      method: 'get'
    })
  },
  // 订单支付确认
  orderPayConfirm(data) {
    return request({
      url: `/jcd-payment/tlPaymentOrder/private/orderPay/confirm`,
      method: 'POST',
      headers: encryptionData(data, '/merchantBrand/page'),
      data: Qs.stringify(data)
    })
  },
  // 查询是否支付完成
  paymentOrderQuery(data) {
    return request({
      method: "post",
      url: "/jcd-payment/tlPaymentOrder/public/paymentOrderQuery",
      headers: encryptionData(data, '/merchantBrand/page'),
      data: Qs.stringify(data)
    });
  },
}